<template>
	<view v-if="userInfo" class="x-estimate-price">
		<view class="desc">预估会员价:</view>
		<view class="symbol">¥</view>
		<view class="value">{{(value * (userInfo.discountRate*1.0/10)).toFixed(2)}}
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'	
	export default {
		props: {
			value: {
				type: Number,
				required: true,
			}
		},
		
		computed: {
			...mapState(['userInfo'])
		},
		
		created() {
			// console.log("xEstimate onLoad is called, this.userInfo=", this.userInfo)
			if (this.userInfo && ((!this.userInfo.discountRate) || (this.userInfo.discountRate <= 0))) {
				//用户存在,但是折扣信息小于等于0,先清除信息，再重新登录
				this.$store.dispatch('clearClientUserInfo');
				uni.navigateTo({
					url: '/pages/login/index'
				})
			}
		},
		
		data() {
			return {

			}
		},


	}
</script>

<style lang="scss" scoped>
	.x-estimate-price {
		display: flex;
		align-items: baseline;
		justify-content: center;
		padding: 4rpx;
		border-radius: 2rpx;
		font-size: 26rpx;
		color: white;
		width: 100%;
		background: #CAAA81;
		// position: absolute;
		// bottom: 15rpx;

		.desc {
			height: 25rpx;
			font-size: 25rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			// color: #2D2D2D;
			line-height: 25rpx;
		}

		.symbol {
			height: 30rpx;
			font-size: 20rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			line-height: 30rpx;
		}

		.value {
			margin-left: 2rpx;
			height: 35rpx;
			font-size: 25rpx;
			font-family: PingFang-SC-Bold, PingFang-SC;
			font-weight: bold;
			line-height: 35rpx;
		}
	}
</style>